package com.neuedu.xkxt.controller;


import com.neuedu.xkxt.result.R;
import com.neuedu.xkxt.service.StudentService;
import com.neuedu.xkxt.vo.CourseVO;
import com.neuedu.xkxt.vo.PageVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping("student")
public class StudentController {
    @Resource
    private StudentService studentService;
    @GetMapping("page")
    public R page(@RequestParam int pageNo, @RequestParam int pageSize,@RequestParam int studentId,@RequestParam int state){
            if (state==0) {
                PageVO<CourseVO> pageVO=studentService.pageUnSelectd(pageNo,pageSize,studentId);
                return new R(200,"查询成功",pageVO);
            }else{
                PageVO<CourseVO> pageVO=studentService.pageSelectd(pageNo,pageSize,studentId);
                return new R(200,"查询成功",pageVO);
            }

    }
    @GetMapping("editCourseState")
    public R editCourseState(@RequestParam int studentId,@RequestParam int courseId,@RequestParam int state){
        int result=studentService.editCourseState(studentId,courseId,state);
        if (result>0) {
            return new R(200,"操作成功",null);
        }else{
            return new R(500,"操作失败",null);
        }
    }

}
